Skip to content

fix: close public share connections when the owner is deactivated or deleted - #417

Merged
LucHeart merged 2 commits into
developfrom
fix/public-share-owner-deactivation
Dec 4, 2026
Merged

LucHeart merged 2 commits into
developfrom
fix/public-share-owner-deactivation

Conversation

@LucHeart

@LucHeart LucHeart commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

When a public share's owner is deactivated or deleted, guests and logged-in visitors connected to that share stayed connected.

  • Hub connections to a public share now record the share's owner.
  • AbortUser (driven by UserAuthRevoked, published only on account deactivation) also closes connections to that user's public shares.
  • Adds Hub_DeactivatingTheOwner_ClosesGuestsAndLoggedInVisitors.
  • Documents the missing redisPubService param on DeletePublicShare.

Summary by CodeRabbit

  • Bug Fixes
    • Connections to a public share now close when its owner’s account is deactivated, including connections from guests and logged-in visitors.
    • Improved consistency when ending access to public shares after account deactivation.

@LucHeart
LucHeart requested a review from hhvrc as a code owner December 4, 2026 00:24
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-04T00:26:22.842204Z 6e97a65 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Public-share hub connections now store the share owner’s ID. When a user’s authentication is revoked, the tracker also closes connections to shares owned by that user. An integration test checks guest and logged-in visitor connections after owner deactivation.

Changes: Public-share connections

Layer / File(s) Summary
Track owners and abort their connections
Common/Hubs/HubConnectionTracker.cs, Common/Hubs/PublicShareHub.cs, API/Realtime/RedisSubscriberService.cs, API/Controller/Shares/Links/DeletePublicShare.cs, API.IntegrationTests/Tests/PublicSharePasswordTests.cs
The tracker stores each public share’s owner ID and matches it when aborting connections for a user. The hub passes the owner ID to the tracker. The integration test checks guest and logged-in visitor connections after owner deactivation. The debug message and XML documentation are updated.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant PublicShareHub
  participant HubConnectionTracker
  participant RedisSubscriberService
  participant TrackedHubConnection
  PublicShareHub->>HubConnectionTracker: TrackPublicShare with owner ID
  RedisSubscriberService->>HubConnectionTracker: AbortUser with user ID
  HubConnectionTracker->>TrackedHubConnection: Abort when owner ID matches
Loading

Possibly related PRs

  • OpenShock/API#416: Adds public-share connection closure on password changes, share deletion, and failed periodic checks.
  • OpenShock/API#407: Adds the tracker and Redis revocation notifications used by this change.
Merge Risk: Minimal · up to 6e97a

Public-share connections now close when the share owner is deactivated, and an integration test covers that behavior. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the primary change: public share connections are closed when the share owner is deactivated or deleted. The raw summary shows hub tracking now records the owner ID and AbortUser closes…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the primary change: public share connections are closed when the share owner is deactivated or deleted. The raw summary shows hub tracking now records the owner ID and AbortUser closes connections to that owner's public shares, which matches the title. The title uses the conventional fix: prefix and is specific enough for a teammate scanning history. The title is 76 characters, which is acceptable.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ef27beb0-363b-4794-af3b-56f941ecda55
Commits

Reviewing files that changed from the base of the PR and between 72b6e5b and 6e97a65.

Files selected for processing: 5

  • API.IntegrationTests/Tests/PublicSharePasswordTests.cs
  • API/Controller/Shares/Links/DeletePublicShare.cs
  • API/Realtime/RedisSubscriberService.cs
  • Common/Hubs/HubConnectionTracker.cs
  • Common/Hubs/PublicShareHub.cs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6e97a65abb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// Closed when the share's password is set or changed, the share is deleted or its owner deactivated. Left unvalidated so the
// first call checks the share again, covering a change made since it was read above.
_connectionTracker.TrackPublicShare(Context, id, share.PasswordStamp);
_connectionTracker.TrackPublicShare(Context, id, share.OwnerId, share.PasswordStamp);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Close connections that race with owner revocation

If the owner is deactivated after the share query at line 70 but before this connection is tracked, the UserAuthRevoked handler can run before PublicShareOwnerId is attached and miss the connection. The reset validation only checks the share on a later hub invocation, so an idle connection can remain open indefinitely despite the owner deactivation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By design. The same window exists for password changes and share deletion (#416) and for session revocation (#407): a connection tracked after the revocation was published is not closed, but it is left unvalidated, so its first hub call checks the share against the database before anything runs. An idle connection that slipped through can't control any shocker.

@LucHeart
LucHeart merged commit 67b6c7f into develop Dec 4, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant